package org.qq.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum DatabaseTypeEnum {
    PRESTO("presto"),
    TRINO("trino"),
    FLINK("flink"),
    SPARK("spark"),
    HIVE("hive"),
    STARROCKS("starrocks"),
    DORIS("doris"),
    REDSHIFT("redshift"),
    MYSQL("mysql"),
    ORACLE("oracle"),
    POSTGRES("postgres"),
    SQLSERVER("sqlserver");


    private final String type;

    DatabaseTypeEnum(String type) {
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public static DatabaseTypeEnum fromString(String type) {
        for (DatabaseTypeEnum value : DatabaseTypeEnum.values()) {
            if (value.getType().equalsIgnoreCase(type)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unsupported database type: " + type);
    }
    // 静态方法返回所有枚举值
    public static List<String> getAllSupportedDatabases() {
        return Arrays.stream(values())
                .map(DatabaseTypeEnum::getType)
                .collect(Collectors.toList());
    }
}